package com.xmb.wechat.view.wechat.chat;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.constraint.Group;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.bean.WechatContactBean;
import com.xmb.wechat.common.Constant;

import butterknife.BindView;

/**
 * @Author lijiangop
 * @CreateTime 2020/4/28 09:25
 */
public class WechatVideoCallDetailActivity extends BaseActivity {

    @BindView(R2.id.iv_bg)
    ImageView mIvBg;
    @BindView(R2.id.iv_avatar_long)
    ImageView mIvAvatarLong;
    @BindView(R2.id.iv_avatar)
    ImageView mIvAvatar;
    @BindView(R2.id.tv_avatar)
    TextView  mTvAvatar;
    @BindView(R2.id.tv_time)
    TextView  mTvTime;
    @BindView(R2.id.gp_on_line)
    Group     mGpOnLine;
    @BindView(R2.id.gp_is_answer)
    Group     mGpIsAnswer;
    @BindView(R2.id.tv_hang_up)
    TextView  mTvHangUp;
    @BindView(R2.id.tv_desc)
    TextView  mTvDesc;

    public WechatVideoCallDetailActivity() {
        super(R.layout.activity_wechat_video_call_detail);
        isChangeStatusBarTxtColor = false;
    }

    public static void start(Context act, boolean isToAnswer, String time, String objectImg, String mineImg, WechatContactBean wechatContactBean) {
        Intent it = new Intent(act, WechatVideoCallDetailActivity.class);
        it.putExtra("wechatContactBean", wechatContactBean);
        it.putExtra("isToAnswer", isToAnswer);
        it.putExtra("objectImg", objectImg);
        it.putExtra("mineImg", mineImg);
        it.putExtra("time", time);
        act.startActivity(it);
    }

    @Override
    protected void initView() {
        setStatusBarColor(Color.parseColor("#000000"));
        setNavigationColor(Color.parseColor("#f7f7f7"));
        //deliver_data
        WechatContactBean wechatContactBean = (WechatContactBean) getIntent().getSerializableExtra("wechatContactBean");
        boolean isToAnswer = getIntent().getBooleanExtra("isToAnswer", false);
        //show
        if (isToAnswer) {//待接听
            String mineImg = getIntent().getStringExtra("mineImg");
            mGpOnLine.setVisibility(View.GONE);
            mGpIsAnswer.setVisibility(View.VISIBLE);
            mTvHangUp.setText("取消");
            if (wechatContactBean != null) {
                if (wechatContactBean.getAvatarSrc() == Constant.SourceType.AVATAR_SRC_SDCARD) {
                    Picasso.get().load("file://" + wechatContactBean.getAvatar()).error(R.drawable.ic_wx_default_avatar)
                            .into(mIvAvatar);
                } else {
                    Picasso.get().load("file:///android_asset/avatars/" + wechatContactBean.getAvatar()).error(R.drawable.ic_wx_default_avatar)
                            .into(mIvAvatar);
                }
                mTvAvatar.setText(TextUtils.isEmpty(wechatContactBean.getName()) ? "" : wechatContactBean.getName());
            }
            mTvDesc.setTextColor(getResources().getColor(R.color.white));
            Picasso.get().load("file://" + mineImg).error(R.drawable.ic_wx_default_avatar).into(mIvBg);
        } else {
            String time = getIntent().getStringExtra("time");
            String objectImg = getIntent().getStringExtra("objectImg");
            String mineImg = getIntent().getStringExtra("mineImg");
            mGpOnLine.setVisibility(View.VISIBLE);
            mGpIsAnswer.setVisibility(View.GONE);
            mTvHangUp.setText("挂断");
            mTvTime.setText(TextUtils.isEmpty(time) ? "" : time);
            Picasso.get().load("file://" + objectImg).error(R.drawable.ic_wx_default_avatar).into(mIvAvatarLong);
            Picasso.get().load("file://" + mineImg).error(R.drawable.ic_wx_default_avatar).into(mIvBg);
        }
    }

}
